package Polymorphism;

import java.util.Scanner;

public class BeveragesTest {
    public static void main(String[] args) {
            System.out.println("欢迎使用饮料机，请认真阅读以下使用说明:");
            System.out.println("[1]矿泉水  [2]可乐  [3]咖啡  [4]退出系统");
            Scanner scanner = new Scanner(System.in);
            System.out.print("请输入编号:");
            int i = scanner.nextInt();
            switch (i) {
                case 1:
                    System.out.println("已经成功购买矿泉水");
                    System.out.println("感谢您的使用");
                    break;
                case 2:
                    System.out.println("请问需要可乐类型:请输入可口可乐or百事可乐");
                    String s = scanner.next();
                    Beverages cola = new Cola();
                    if (cola instanceof Beverages) {
                        Cola cola1 = (Cola) cola;
                        cola1.choose(s);
                    }
                    break;
                case 3:
                    System.out.println("请问咖啡是否需要加奶加糖:请输入加糖or加奶or加糖加奶or都不加");
                    String y = scanner.next();
                    Beverages coffee = new Coffee();
                    if (coffee instanceof Beverages) {
                        Coffee coffee1 = (Coffee) coffee;
                        coffee1.add(y);
                    }
                    break;
                case 4:
                    System.exit(0);
                    break;
                default:
                    System.out.println("错误");

            }
        }
    }

